home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Tele
/
Pete Johnson
/
Flip 1.0.3<source>.cpt
/
TxWrite.p
< prev
next >
Wrap
Text File
|
1990-08-18
|
2KB
|
80 lines
unit TxWrite;
interface
uses
HelloTabby;
procedure MakeTextFile (FileName: STR255);
function AtEOF (fRefNum: Integer): Boolean;
function Wr (FileRefNum: integer; TheMessage: str255): OSErr;
function WrLn (FileRefNum: integer; TheMessage: str255): OSErr;
implementation
{----------------------------------------------------------------- }
procedure MakeTextFile;
{ Sets up QUED-compatible text file }
var
fndrInfo: FInfo;
begin
Err := GetFInfo(FileName, vRefNum, fndrInfo);
if Err = noErr then
begin
fndrInfo.fdType := 'TEXT';
fndrInfo.fdCreator := 'QED1';
Err := SetFInfo(FileName, vRefNum, fndrInfo);
end
else
Err := Create(FileName, vRefNum, 'QED1', 'TEXT');
end;
{ ------------------------------------------------------ }
function AtEOF;
var
Err: OSErr;
currPos, eofPos: LongInt;
begin
Err := GetFPos(fRefNum, currPos);
Err := GetEOF(fRefNum, eofPos);
AtEOF := currPos = eofPos
end;
{ ------------------------------------------------------ }
function Wr;
{ Writes string (without length byte) to text file, returns error code }
var
TheLength: longint;
begin
TheLength := length(TheMessage);
Wr := FSWrite(FileRefNum, TheLength, Pointer(ord(@TheMessage) + 1))
end;
{ ------------------------------------------------------ }
function WrLn;
{ Writes string (without length byte) to text file, returns error code }
const
ENDLINE = chr(13);
begin
TheMessage := concat(TheMessage, ENDLINE);
WrLn := Wr(FileRefNum, TheMessage)
end;
{ ------------------------------------------------------ }
end.